<template>
  <div class="wh">
    <commonshownum :type="'liuliang'" :num="numval" :typestr.sync="typestr" :componentDetail="componentDetail"/>
  </div>
</template>
<script>
import commonmixins from "@/mixins/bigScreen/commonmixins";
import axios from "@/utils/requestdp";
import dayjs from "dayjs";

export default {
  mixins: [commonmixins],
  name: "liuliangnumtaian",
  components: {},
  data() {
    return {
      numval: "-",
      typestr: "总流量·m³/h",
    };
  },
  computed: {},
  mounted() {
    this.watchEvent();
  },
  methods: {
    watchEvent() {
      //先清除定时任务
      if (this.$store.state.daping.intervalArr["liuliangnumtaian"] != undefined) {
        return;
      }
      this.loadData();
      let interval = setInterval(() => {
        this.loadData();
      }, this.$root.setting.data.interval);
      this.$store.state.daping.intervalArr["liuliangnumtaian"] = [
        { interval: interval },
      ];
    },
    loadData() {
      let day = dayjs().format("YYYY-MM-DD");

      let st = dayjs(day + " 00:00:00").unix();
      let et = dayjs(day + " 23:59:59").unix();


      let queryJson = {
        queries: [
          {
            metric: "id,sa_001heatare/10000 as sa_001heatare",
            schema: "daily",
          },
        ],
        endTime: et,
        startTime: st,
        table: "pipenet",
        orderBy: "aligntime",
        search: "id=0",
      };

      // axios.post("/open/queryDb", queryJson).then((res) => {
      //   //如果有则获取200中的结果
      //   if (res.code == 200 && res.data[0]) {
      //     this.$store.state.daping.liuliangnumtaian = res.data[0]['sa_001heatare'];
      //     this.numval = parseInt(res.data[0]['sa_001heatare'])
      //   }
      // });
    },
  }
};
</script>
<style lang='scss' scoped>
</style>